const {User} = require('../../model/user');
module.exports = async (req,res)=>{
    //记录当前访问的页面
    req.app.locals.currentLink = 'user';
    //接收客户端传递来的当前页参数
    let page = req.query.page || 1;
    let pagesize = 10;
    //查询数据的总条数
    const count = await User.countDocuments({});
    let total = Math.ceil(count/pagesize);
    let start = (page -1) * pagesize;
    let users =await User.find({}).limit(pagesize).skip(start);
    res.render('admin/user',{
        users: users,
        page: page,
        total: total
    });
}